import request from '@/utils/request'

export function getAllRole(query) {
  return request({
    url: '/api/role/',
    method: 'get',
    params: query
  })
}

// 以树的结构获取角色
export function getRoleTree(params) {
  return request({
    url: '/api/role/list_by_tree/',
    method: 'get',
    params: params
  })
}

export function updateRole(id, data) {
  return request({
    url: '/api/role/' + id + '/',
    method: 'patch',
    headers: {
      'Content-Type': 'application/json'
    },
    data: data
  })
}

export function getPermissionTree(query) {
  return request({
    url: '/api/permission/',
    method: 'get',
    params: query
  })
}
